import React from "react";
import { Editor, EditorState } from "draft-js";
import "draft-js/dist/Draft.css";

export default function MyEditor() {
	const [editorState, setEditorState] = React.useState(() => EditorState.createEmpty());

	const editor = React.useRef<any>(null);
	function focusEditor() {
		if (editor.current) {
			editor.current.focus();
		}
	}

	return (
		<div style={{ border: "1px solid black", minHeight: "6em", cursor: "text" }} onClick={focusEditor}>
			<Editor ref={editor} editorState={editorState} onChange={setEditorState} placeholder="Write something!" />
		</div>
	);
}
